<?php

session_start();
/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */

/**
 * Description of TableGridClass
 *
 * @author Administrador
 */
class TableGridClass {
    /*
     * To change this license header, choose License Headers in Project Properties.
     * To change this template file, choose Tools | Templates
     * and open the template in the editor.
     * Description of ComponentClass
     *
     * @author Administrador
     */

    private $tableTitle;
    private $tableGrid;
    private $divID;
    private $tableColumnHeads;
    private $columns;
    private $content;

    function __construct() {
        $this->setTableGrid($divID);
        $this->columns = array();
        $this->tableColumnHeads = "";
        $this->tableTitle="";
        $this->content = "";
    }

    public function setTableTitle($tableTitle) {
        $this->tableTitle = $tableTitle;
    }

  

    public static function LIB($path) {
        echo " <link rel=\"stylesheet\" type=\"text/css\" href=\"../bootstrap/css/DT_bootstrap.css\">
        <style type=\"text/css\" title=\"currentStyle\">
            @import \"" . $path . "component/datagrid/media/css/demo_page.css\"; 
            @import \"" . $path . "component/datagrid/media/css/header.css\";
            @import \"" . $path . "component/datagrid/media/css/demo_table.css\";
        </style>
        <script type=\"text/javascript\" language=\"javascript\" src=\"" . $path . "component/datagrid/media/js/jquery.js\"></script>
        <script type=\"text/javascript\" language=\"javascript\" src=\"" . $path . "component/datagrid/media/js/jquery.dataTables.js\"></script>";
    }

    private function setTableGrid($divID) {
        $this->divID = $divID;
        $_SESSION['DivId']=$divID;
        $this->tableGrid = " 
            <script type=\"text/javascript\" charset=\"utf-8\">
            var asInitVals = new Array();

            $(document).ready(function() {
                var oTable = $('#TableGrid').dataTable({
                    \"oLanguage\": {
                        \"sSearch\": \"Search all columns:\"
                    }
                });


            });
        </script>";

        echo "" . $this->tableGrid;
    }

    
   public function setTableContent($content) {
        $this->content = $content; 
    } 
    
  
/*
    public function setTableContent($result) {

        $content = "";
        
        while ($row = mysql_fetch_array($result)) {
            $content = $content . "<tr>";
            foreach ($this->columns as $value) {
                $content = $content . "<td>" . $row[$value] . "</td>";
            }
            
            $content = $content . "</tr>";
        }
        $this->setContent($content);    
    }
 * 
 */

    public function getTableContent() {
        return $this->content;
    }
    
    
    public function keepTableGrid(){
       $_SESSION['TableGrid']= "<div class=\"panel panel-default\">
      <div class=\"panel-heading\">
      <h3 class=\"panel-title\">" .$this->tableTitle . "</h3>
      </div>
      <div class=\"panel-body\">
      <div>
      <table cellpadding=\"0\" cellspacing=\"0\" border=\"0\"
      class=\"table table-striped table-bordered table-condensed table-responsiv\" id=\"TableGrid\">
      " . $this->getTableContent() . "
      </table>
      </div>
      </div>
      </div>";
    }
   
    public function showTable(){
        echo $_SESSION['TableGrid'];
        $_SESSION['TableGrid']="";
    }
     
   
    /*  
    public function showTable() {
        echo "<div class=\"panel panel-default\">
      <div class=\"panel-heading\">
      <h3 class=\"panel-title\">" .$_SESSION['TableGridTitle'] . "</h3>
      </div>
      <div class=\"panel-body\">
      <div>
      <table cellpadding=\"0\" cellspacing=\"0\" border=\"0\"
      class=\"table table-striped table-bordered table-condensed table-responsiv\" id=\"" . $this->divID . "\">
      <thead>
      <tr>
      " . "<td>1</td><td>2</td><td>3</td>" . "
      </tr>
      </thead>
      <tbody>
      " . $_SESSION['TableGridContent'] . "
      </tbody>
      </table>
      </div>
      </div>
      </div>";
     
     * 
     */
   
}

//put your code her
